{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# livelossplot example: Neptune.AI\n",
    "\n",
    "Since `livelossplot 0.3.2`. API change in `0.5.0`. Integration by [Kamil Kaczmarek](https://github.com/kamil-kaczmarek) from Neptune.\n",
    "\n",
    "You need [Neptune.AI account](https://neptune.ai/welcome-back).\n",
    "\n",
    "<a href=\"https://colab.research.google.com/github/stared/livelossplot/blob/master/examples/keras.ipynb\" target=\"_parent\">\n",
    "    <img src=\"https://colab.research.google.com/assets/colab-badge.svg\"/>\n",
    "</a>\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip install neptune-client livelossplot --quiet"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from time import sleep\n",
    "\n",
    "import numpy as np\n",
    "\n",
    "from livelossplot import PlotLosses\n",
    "from livelossplot.outputs import NeptuneLogger"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# local run\n",
    "api_token = os.environ.get('NEPTUNE_API_TOKEN')\n",
    "project_qualified_name = os.environ.get('NEPTUNE_PROJECT_NAME')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "plotlosses = PlotLosses(outputs=[NeptuneLogger(api_token=api_token, project_qualified_name=project_qualified_name)])\n",
    "\n",
    "for i in range(20):\n",
    "    plotlosses.update({\n",
    "        'accuracy': 1 - np.random.rand() / (i + 2.),\n",
    "        'val_accuracy': 1 - np.random.rand() / (i + 0.5),\n",
    "        'mse': 1. / (i + 2.),\n",
    "        'val_mse': 1. / (i + 0.5)\n",
    "    })\n",
    "    plotlosses.send()\n",
    "    sleep(.5)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.4"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "source": [],
    "metadata": {
     "collapsed": false
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}